package com.myapplication.interfaces;

import com.myapplication.callback.GoodsInfoCallback;
import com.myapplication.http.util.HttpFail;
import com.myapplication.http.util.Util;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by zskzh on 2016/7/9.
 */
public class GoodsInfoConnect implements GoodsInfoInter {
    @Override
    public void getGoodsInfo(String good_id, final GoodsInfoCallback goodsInfoCallback) {
        RequestParams requestParams = new RequestParams(Util.UrlGetGoodsInfo);
        requestParams.addBodyParameter("goods_id", good_id);
        x.http().get(requestParams, new Callback.CommonCallback<String>() {
            @Override
            public void onSuccess(String result) {
                goodsInfoCallback.onGoodsInfoSuccess(result);
            }

            @Override
            public void onError(Throwable ex, boolean isOnCallback) {
                String a = HttpFail.onError(ex, isOnCallback);
                goodsInfoCallback.onGoodsInfoFail(a);
            }

            @Override
            public void onCancelled(CancelledException cex) {

            }

            @Override
            public void onFinished() {

            }
        });
    }
}
